home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MPW C++ / MPW C++ PQR4 / New Features in 3.2 C++ < prev   
Text File  |  1991-04-30  |  18KB  |  466 lines

  1. Wednesday, April 17, 1991 5:04:35 PM
  2. New features added to MPW C++ since 3.1 final:  (This file describes
  3. changes going backwards in time, with the most recent changes first.)
  4.  
  5. The only substantial feature we have promised for 3.2 alpha that is not in
  6. this version is the AT&T CFront 2.1.0 merge.  This CFront is based on
  7. AT&T's 2.0 version.
  8.  
  9. ----------------------------------------------
  10. Changes in CFront 1.1d16 (a.k.a. CPlus 3.2d16)
  11. Added code to remove dump files when CFront exits with an error status.
  12.  
  13.  
  14.  
  15. ----------------------------------------------
  16. Changes in CFront 1.1d16 (a.k.a. CPlus 3.2d16)
  17. Fixed a "rehash failed" bug.
  18. Changed constructor optimization (-z15) warnings to only come out with the
  19. -w2 option.
  20.  
  21.  
  22.  
  23. ----------------------------------------------
  24. Changes in CFront 1.1d15 (a.k.a. CPlus 3.2d15)
  25. In d13, any inline function that CFront "outlines" (most commonly a virtual
  26. function whose body appears inside the class definition) causes CFront to
  27. abort.  D14 fixes this, but fixes it inadequately; d15, we hope, is right.
  28.  
  29.  
  30.  
  31. ----------------------------------------------
  32. Changes in CFront 1.1d13 (a.k.a. CPlus 3.2d13)
  33. (d11 and d12 were buggy and did not go into wide distribution.)  This
  34. version implements "-model far" ("32-bit everything") properly and fixes a
  35. MacApp bug.
  36.  
  37.  
  38. WARNING:  To use "-model far" you need to have new libraries and a new C
  39. compiler:
  40. 1.  You need the C compiler released for the ETO #3 disk or later.  This
  41. will be a C compiler with version "3.2b5q113experimental" or later.  Earlier
  42. C compilers simply do not support model far.  (With model far, the C
  43. compiler is doing most of the work.  All CFront does differently is create
  44. different method tables for Pascal objects.)
  45.  
  46. 2.  You need a new ObjLib.o in {Libraries} if you are building a MPW tool
  47. (not an application) that has objects derived from PascalObject.  The old
  48. ObjLib.o does not support "model far" method dispatch.
  49.  
  50. 3.  You need a new MacApp library (MacApp 3.0; must support "qModelFar") if
  51. you are using MacApp.  (The reason is the same as above:  the old MacApp
  52. library only supports "model near" method dispatch.)
  53.  
  54. 4.  You need a new Runtime.o in {Libraries} if you are building just about
  55. anything.  (Technically, the old one will work if you have no global or
  56. static objects that have constructors or destructors.  The library code
  57. that executes the constructors and destructors for global and static
  58. objects breaks for "model far".  Your program will get a bus-error when it
  59. calls its destructors before terminating.)  You need version "3.2b7exp2" or
  60. later.
  61.  
  62.  
  63.  
  64. MacApp bug fixed:  Consider the following code fragment:
  65.  
  66.     class TParent : PascalObject {
  67.         virtual pascal void VFunc();
  68.         TParent *fParent;
  69.     };
  70.     pascal void TParent::VFunc()
  71.     {
  72.         fParent->VFunc();
  73.         fParent->TParent::VFunc();
  74.     }
  75.  
  76. According to the rules of C++, the first VFunc() call should use method
  77. dispatch and the second one should not.  (It will call TPARENT_VFUNC(), not
  78. TPARENT$VFUNC().)  CFront 1.1d10 and older versions would NOT use method
  79. dispatch for either one.  This would happen only when the function called
  80. is the same as the one you are in -- i.e. you have what looks like
  81. recursion (but actually isn't).  In other contexts it would be correct. Now
  82. it is correct in all cases.
  83.  
  84. This is a "MacApp bug" simply because it turned up in a MacApp 3.0 test
  85. program and MacApp users would be more likely to see it than people who
  86. don't use PascalObject a lot.
  87.  
  88.  
  89.  
  90.  
  91. ----------------------------------------------
  92. Changes in CFront 1.1d10 (a.k.a. CPlus 3.2d10)
  93. 1.1d10 fixes a bug in which, if you have EXACTLY 256 virtual functions in a
  94. class's virtual table, any class derived from that class will have its
  95. virtual table misaligned.  Also true of 512, 768 etc. -- any positive
  96. number divisible by 256.
  97.  
  98. There is also a -z18 option that prints out some memory usage statistics. 
  99. I am not sure these will be of interest to anyone except the C++ team right
  100. now.  I am not entirely sure they are right.  The numbers reported here will
  101. not be the same numbers you see if you look at the memory usage window in
  102. the Finder while CFront is running.
  103.  
  104.  
  105.  
  106. ----------------------------------------------
  107. Changes in CFront 1.1d9 (a.k.a. CPlus 3.2d9)
  108. Bug fix:  CFront generates C names for anonymous unions.  (Usually they
  109. look like "__C359" or "__O359".)  In very large examples it would sometimes
  110. leave these names out. It turned out to be misnumbering them because it
  111. only allowed an unsigned char for anonymous union names -- when this
  112. overflowed, it would mis-generate names.  We have widened this field to a
  113. short.  (AT&T's code for 2.1.0 also has this field widened to a short.) 
  114. Unfortunately, this also means that dump files made with earlier compilers
  115. will not be compatible with d9, and you will have to rebuild your dump
  116. files.
  117.  
  118. Bug fix:  1.1d8 CFront generates expressions like this:
  119.  
  120.     __F2?__dt__9TClassOneFv( __F2, 2) :(((void )0));
  121.     
  122. for lazy-evaluated destructor calls -- note the void cast on 0 so that both
  123. legs of the conditional operator have void type.  This cast was added
  124. because earlier CFronts did not generate correct ANSI C code here.  (ANSI C
  125. requires that both legs be void if one is.)  This fix introduced a new
  126. problem, which we fixed in 1.1d9.
  127.  
  128.  
  129.  
  130. --------------------------------------------
  131. Changes in CFront 1.1d8 (a.k.a. CPlus 3.2d8)
  132. This is the first release that allows 32-bit PascalObjects.  (This is the
  133. -model far option.)  It also fixes a code generation bug that did not
  134. bother MPW C, but which was not correct ANSI C.
  135.  
  136.  
  137. -model far
  138. This option turns on 32-bit data and code references.  By default ("model
  139. near"), these references are a5-relative.  "Model far" allows a larger
  140. address space than the traditional Macintosh model.
  141.  
  142. If you do not have any classes derived from PascalObject, all CFront does
  143. with "model far" is pass it along to the C compiler, and the C compiler
  144. generates all the references differently.
  145.  
  146. If you have classes derived from PascalObject, CFront generates such
  147. objects differently. The Pascal method tables are different for "model far"
  148. and the objects are larger.  Specifically, with "model near", each Pascal
  149. object has a 2-byte field identifying what class it belongs to.  With "model
  150. far", this field is 4 bytes long.  This means that the same class
  151. declaration will yield objects of different sizes, with different offsets,
  152. if it is compiled "model far" rather than "model near".
  153.  
  154. Therefore it is dangerous to link compilation units that have been compiled
  155. with "model near" with compilation units compiled with "model far".  If
  156. both compilation units have code that manipulates objects of the same
  157. Pascal object type, they will be incompatible, because the field offsets
  158. will not match.  The Linker will warn you if you make questionable mixes of
  159. this kind.  The solution is to either compile everything with the same
  160. memory model, or at least collect all the code that manipulates a
  161. particular Pascal object type and compile it with the same memory model.
  162.  
  163. Example:  struct TThing : PascalObject { short a, b, c; }
  164.  
  165. would be 8 bytes long if compiled with "model near", 12 if compiled with
  166. "model far".  (That is, for "model near", 8 = 2 + 2 + 2 + 2, where the
  167. first 2 identify the class at runtime.  For "model far", 12 = 4 + 2 + 2 + 2
  168. + 2, where the first 4 identify the class and the last 2 pad the struct out
  169. to a 4-byte boundary.)
  170.  
  171.  
  172. 1.1d8 generates "model bits" on function modules to warn the Linker that a
  173. function uses fields of a PascalObject.  However, current C compilers do
  174. not support this, so this is turned off unless you use -z20.  -z20 is not a
  175. permanent option and will eventually become the default.
  176.  
  177.  
  178.  
  179. WARNING:  DO NOT build code with "model far" PascalObjects if you do not
  180. have a MacApp library that supports "model far" (in MacApp lingo,
  181. "qModelFar") or at least an MPW ObjLib.o library that supports it.  The
  182. existing library code that supports Pascal method dispatches does not work
  183. with "model far"! (The library functions that change are:  %_METHOD,
  184. %_NEWMETHOD, %_OBNEW and perhaps others.)
  185.  
  186. This warning goes for ALL applications built with MacApp, since all MacApp
  187. objects are derived from TObject, and TObject is derived from PascalObject.
  188.  
  189.  
  190.  
  191.  
  192.  
  193. ----------------------------------------------
  194. Changes in CFront 1.1d7 (a.k.a. CPlus 3.2d7):
  195. This release adds the -z15 and -z17 options, and refines the -z14 option
  196. further.
  197.  
  198.  
  199.  
  200. -z17
  201. CFront refuses to inline-expand functions greater than a certain size --
  202. usually about 12 assignment statements is enough to cause an inline
  203. function to be "outlined". -z17 turns this restriction off, so no matter
  204. how large a function is, it will still be expanded inline.
  205.  
  206. We found it necessary to do this in order to get full value out of the -z15
  207. optimizations.  In deeply-nested object hierarchies that use multiple
  208. inheritance, a constructor can easily exceed the built-in size limit.  Such
  209. a constructor will then be "outlined", which means that the optimization
  210. cannot be done.  The optimization will make it smaller, but because it is
  211. done after the size is evaluated, that does not help.
  212.  
  213. If you have any doubts about whether this changes the number of
  214. optimizations, compile the same thing with and without -z17 (using -z14 in
  215. both cases) and count the number of optimization warnings.
  216.  
  217. Be careful with this:  in some examples, some expressions are so deeply
  218. nested that the C compiler cannot handle them.  (This may happen anyway,
  219. but happens more often if you use -z17.)  If this causes trouble, either
  220. don't use -z17 or else change the HEXA resource for the MPW Shell to allow
  221. a bigger stack size.  (This is described in the Release Notes for MPW C++
  222. 3.1.)
  223.  
  224.  
  225.  
  226.  
  227. -z16
  228. -z16 is reserved for debugging.  It is not used in released compilers.
  229.  
  230.  
  231.  
  232.  
  233. -z15
  234. -z15 causes the -z14 optimizations to occur even for cases using multiple
  235. inheritance.  At this writing (September 1990) I am not satisfied that this
  236. is a correct optimization for multiple inheritance.  I have not been able
  237. to construct a counterexample, but there might be one out there.  Therefore
  238. I wanted to flag -z15 as being more risky than -z14.
  239.  
  240. -z15 implies -z14.  If you say both -z14 and -z15, that is the same as just
  241. saying -z15.
  242.  
  243. [Postscript, February 1991.  We are satisfied now that this is a correct
  244. optimization for multiple inheritance.  -z14 will be removed at some time
  245. in the future and only -z15 -- which does both multiple and single
  246. inheritance cases -- will be available.]
  247.  
  248.  
  249.  
  250. -z14 (changes)
  251. This optimization has been extended so that it removes redundant vptr
  252. initializations. See the description of -z14 below.
  253.  
  254.  
  255.  
  256.  
  257.  
  258. ----------------------------------------------
  259. Changes in CFront 1.1d6 (a.k.a. CPlus 3.2d6):
  260. This release adds the -z14 and -z5 options.
  261. -z14
  262. -z14 causes some of the allocation code for nested inline constructors to
  263. be optimized away.  Suppose that you have two classes, "Base" and
  264. "Derived", and "Base" has a constructor or a virtual function.  (If it has
  265. a virtual function, CFront will create a constructor for it if the user
  266. does not make one.  The purpose of this constructor is to set the vptr for
  267. the object.) When a Derived object is created, its constructor will call
  268. the Base constructor.  When the calls for Derived::Derived() and
  269. Base::Base() are expanded inline, some allocation code turns out to be
  270. redundant. -z14 removes this code.
  271.  
  272. Because this is a new optimization, we recommend that you do not develop
  273. code with -z14 on.  Make sure your program works to your satisfaction
  274. without -z14 first, and then try it again with -z14.  If it stops working
  275. properly, stop using -z14, and please notify us (AppleLink CPLUS.BUGS)
  276. explaining the circumstances under which it does the wrong thing.
  277.  
  278. -z14 will issue a warning when it optimizes something.  It may sometimes be
  279. difficult to locate the code that corresponds to this warning in your
  280. program, because when it occurs CFront is in the middle of an inline
  281. expansion.
  282.  
  283. Here is a sample program you can try to see the difference in generated
  284. code with and without -z14:
  285.  
  286.     struct Base
  287.     {
  288.         virtual void f();
  289.         int Bfield;
  290.     };
  291.     
  292.     struct Derived : public Base
  293.     {
  294.         void f();
  295.         int Dfield;
  296.     };
  297.     
  298.     main()
  299.     {
  300.         Derived * p = new Derived;
  301.     }
  302.  
  303.  
  304. Without -z14, the code generated to do the "new Derived" call will look
  305. like this:
  306.  
  307.     struct Derived *p;
  308.     struct Derived *__Xthis00b;
  309.     p = ((__Xthis00b = 0),
  310.         ((    (__Xthis00b ||
  311.                 (__Xthis00b = (struct Derived *) __nw__FUi(sizeof(struct Derived))))
  312.             ?
  313.             (    (__Xthis00b =
  314.                     (struct Derived *)
  315.                     (
  316.                         (
  317.                             (
  318.                                 (((struct Base *) __Xthis00b))
  319.                                 || (__nw__FUi(sizeof(struct Base)))
  320.                             )
  321.                             ? ((((struct Base *) __Xthis00b))->__vptr
  322.                                         = (struct __mptr *) __ptbl__4Base)
  323.                             : 0
  324.                         ),
  325.                         (((struct Base *) __Xthis00b))
  326.                     )
  327.                 ),
  328.                 (__Xthis00b->__vptr = (struct __mptr *) __ptbl__7Derived)
  329.             )
  330.             : 0),
  331.         __Xthis00b)
  332.         );
  333.  
  334.  
  335.  
  336. With -z14, it looks like this:
  337.  
  338.     struct Derived *p;
  339.     struct Derived *__Xthis00b;
  340.     p = ((__Xthis00b = 0),
  341.         ((    (__Xthis00b ||
  342.                 (__Xthis00b = (struct Derived *) __nw__FUi(sizeof(struct Derived))))
  343.             ?
  344.             (    (__Xthis00b =
  345.                     (struct Derived *)
  346.                     (
  347.                         (0),
  348.                         (((struct Base *) __Xthis00b))
  349.                     )
  350.                 ),
  351.                 (__Xthis00b->__vptr = (struct __mptr *) __ptbl__7Derived)
  352.             )
  353.             : 0),
  354.         __Xthis00b)
  355.         );
  356.  
  357.  
  358. The inner test of __Xthis00b and the call to __nw__FUi(sizeof(struct Base))
  359. have been removed. They are not necessary because in the outer context
  360. __Xthis00b has already been tested and __nw__FUi(sizeof(struct Derived))
  361. has already been used to initialize it.
  362.  
  363. The first vptr initialization has also been removed, because it gets done
  364. again afterwards. This part of the optimization would not be done if Base
  365. had a non-empty user-defined constructor. (Note that here what you are
  366. actually getting is an inline-expanded compiler-generated constructor for
  367. Base and Derived.  You can see these plainly if you compile with -z0, which
  368. turns off all inlining.)
  369.  
  370. (The optimization to remove the vptr initialization was added in 3.2d7; the
  371. rest of it was done in 3.2d6.)
  372.  
  373. Some of this code, e.g. the (0) expression, is just useless nonsense.  The
  374. MPW C compiler will not generate any code for this.
  375.  
  376. This particular example, when run through the MPW C 3.2b1 compiler, has
  377. main() being 122 bytes long in the unoptimized version and 78 bytes long in
  378. the optimized version.  Therefore using -z14 saved 44 bytes of code here.
  379.  
  380. This optimization can only be done where constructors are inline-expanded. 
  381. It takes advantage of the code that appears when one constructor is
  382. inline-expanded within another.
  383.  
  384. This optimization does not occur for objects derived from PascalObject. 
  385. Such objects use Pascal method tables instead of C++ vtables and the
  386. allocation code is completely different.
  387.  
  388. This optimization DOES occur for objects derived from HandleObject or
  389. SingleObject.
  390.  
  391.  
  392. The compiler will issue a warning where these optimizations occur.
  393.  
  394.  
  395.  
  396. Areas where -z14 may cause trouble:
  397. (1) If you assign to "this" in your constructors, -z14 may do an incorrect
  398. optimization.  I have not been able to create a test case in which this
  399. occurs, but I suspect it may happen.
  400.  
  401. (2) If you overload operator "new", either globally or locally, and have it
  402. do something other than allocation (e.g. it has interesting side effects,
  403. printfs() or whatever), the -z14 code may not be what you expect.  I have
  404. not been able to create a test case in which this occurs, but I suspect it
  405. may happen.
  406.  
  407.  
  408. This optimization will not be done where multiple inheritance is used.  It
  409. only occurs with classes that only have one base class.  (You do not have
  410. to derive from SingleObject to get this optimization, though.)  If you want
  411. this also to be done with multiple inheritance, use -z15 instead.  (See
  412. the section on 3.2d7 above.  -z15 does not exist in 3.2d6.)
  413.  
  414. To get full value out of this optimization, try the -z17 option at the same
  415. time, which will keep some of the larger constructors from being
  416. "outlined".  (See the section on 3.2d7 above.  -z17 does not exist in
  417. 3.2d6.)
  418.  
  419.  
  420.  
  421. -z5
  422. -z5 stops the linker from stripping static objects that are never used, but
  423. that have constructors or destructors.  According to Bjarne Stroustrup,
  424. these constructors and destructors must be run for their side effects. The
  425. default behavior at Apple is to strip them, and that is what most users are
  426. accustomed to, so we made this an option.
  427.  
  428. C++ code ported to MPW C++ from some other environment should be compiled
  429. with -z5, because it's likely that the people who developed that code
  430. assumed all static object constructors and destructors would be executed.
  431.  
  432.  
  433.  
  434.  
  435. ---------------------------------------------
  436. Changes in CFront 1.1d5 (a.k.a. CPlus 3.2d5):
  437. CFront 1.1d5 was essentially the same thing as C++ 3.1 final (CFront 1.0). 
  438. 1.1d5 was made BEFORE 3.1 final and its changes were rolled into 3.1 final.
  439.  There are some cosmetic differences -- that's all.  (For example, the
  440. Commando resource should list -opt as one of the options passed to the C
  441. compiler.  This is not mentioned in 3.1 final because the MPW 3.1 C
  442. compiler does not allow -opt.  It's a hidden option in 3.1 final.)
  443.  
  444.  
  445.  
  446.  
  447. There were NEVER any releases 1.1d1-1.1d4.  We skipped those numbers in
  448. order to avoid confusion with the 3.1 (CFront 1.0) beta release numbers
  449. (3.1b1, b2, b3, b4).
  450.  
  451.  
  452.  
  453. Things expected, but not yet done:
  454. 3.2 C++ will have AT&T CFront 2.1.0 rolled into it.  This is a bug-fix
  455. release from AT&T and has no new features.  We haven't put it in yet.
  456.  
  457.  
  458.  
  459. Bugs to CPLUS.BUGS on AppleLink, or Mark Bjerke on QuickMail.
  460. Questions about this document to me (Preston Gardner).
  461.  
  462. The C++ team is:
  463. Harvey Alcabes (Product Marketing)
  464. Mark Bjerke (Development Systems Group)
  465. Preston Gardner (Development Systems Group)
  466.